<?php

class CTableDraw
{

public static $instance; 

public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new CTableDraw();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	

function DrawTable($title,$table,$campos)//obligatorio ID como campo inicial
    {
 
 
     $qu="select ";
    $i = 0;
    $i = 0;
    foreach($campos as $id=>$valor)
    {
    $qu=$qu."$id,";


    }
    $qu=substr($qu,0,strlen($qu)-1);
    $qu=$qu." from "."$table";
    
    echo $qu;
     echo "<div id='content_area_user_title'>";
    echo "<h2> $title</h2>";
    echo "</div>";


    echo "<form>";						
    echo "<form id='filter-form'>Buscar TC: <input name='filter' id='filter' value='' maxlength='30' size='30' type='text'></form><br>";
    echo "</form>";
   
    echo "<div class='usersettings_statistics'>"; 
 


    echo "<table class='food_planner'><thead><tr><th colspan='2'></th><tr></thead>";
    echo "<tbody><tr style='display: table-row;'>";

     //echo "<table> <tbody>";

    foreach($campos as $id=>$valor){
  
    echo "<td><h3>$valor</h3></td>";
    
    }
 echo "<tr class='odd'>";
  foreach($campos as $id=>$valor){
  
    echo "<td><input type='text' name='$id' class='general-textarea'></td>";
    
    }
    
    // $qu="select*from $table";
    $table=CModelo::getInstance()->getData($qu);
//var_dump($table);
    $cont=0;
    
    $ruta=CConfig::getInstance()->rutalocal;
    
    
    foreach($table as $campo => $valor)
    { 



$cont=$cont+1;
if($cont%2){




echo "<tr class='odd'>";
$i="";$cont=0;
foreach($valor as $id=>$val)
{ if($cont==0){$i=$val;}

echo "<td width='10%'>$val</td>";$cont=$cont+1;
}
/*---------------------------------------------------------------------------*/
// las referencias debbden de ser modificadas deacuerdo al directorio
//
/*---------------------------------------------------------------------------*/
echo "<td> <a href='$ruta/MDGuideData/CGuideEdit.php?codigo=$i&default=1'>Editar</a> </td>";
echo "<td><a href='/Christian Monzon1/modificar.php?codigo=$i'>Eliminar</a> </td>";
echo "<td> <input type=button onClick=\"parent.location='$ruta/MDGuideData/CGuideTable.php?codigo=$i&default=1'\" value='Ver tours'>  </td>";
echo "</tr>";
}
else
{
$url="asf";
echo "<tr class='even'> ";
$i2="";$cont2=0;
foreach($valor as $id => $val)
{ if($cont2==0){$i2=$val;}
echo "<td width='10%'>$val </td>";$cont2=$cont2+1;
}
echo "<td> <a href='$ruta/MDGuideData/CGuideEdit.php?codigo=$i&default=1'>Editar</a> </td>";
echo "<td><a href='/Christian Monzon1/modificar.php?codigo=$i2'>Eliminar</a> </td>";
echo "<td> <input type=button onClick=\"parent.location='$ruta/MDGuideData/CGuideTable.php?codigo=$i&default=1'\" value='Ver tours'>  </td>";
echo "</tr>";
}

}
echo "</td></tr></tbody></table><br><br>";


echo "</div>";

} 



}
?>